package com.example.sqlSession;

import com.example.config.XMLconfigBuilder;
import com.example.pojo.Configuration;
import org.dom4j.DocumentException;

import java.beans.PropertyVetoException;
import java.io.InputStream;

public class SqlSessionFactoryBuilder {

    public SqlSessionFactory builder(InputStream in) throws PropertyVetoException, DocumentException {

        //使用dom4j,将解析出来的内容封装到 configuration
        XMLconfigBuilder xmLconfigBuilder = new XMLconfigBuilder();
        Configuration configuration = xmLconfigBuilder.parseConfig(in);


        // 创建SqlSessionFactory类：工厂类 生产sqlsession 会话对象

        DefaultSqlSessionFactory defaultSqlSessionFactory = new DefaultSqlSessionFactory(configuration);

        return defaultSqlSessionFactory;
    }

}
